import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

export default new Router({
  mode: 'history',
  routes: [
    // 首页
    {
      path: '/',
      name: 'renting',
      component(resolve) {
        require.ensure(['../pages/renting-car.vue'], () => {
          resolve(require('../pages/renting-car.vue'))
        })
      }
      // meta: { requiresAuth: true }
    },
    // 登录注册集合页
    {
      path: '/login',
      name: 'login',
      component (resolve) {
        require.ensure(['../pages/login.vue'], () => {
          resolve(require('../pages/login.vue'))
        })
      }
    },
    // 首页查询后的结果页
    {
      path: '/search-result',
      name: 'searchResult',
      component(resolve) {
        require.ensure(['../pages/search-result.vue'], () => {
          resolve(require('../pages/search-result.vue'))
        })
      }
    },
    // 个人中心页
    {
      path: '/profile',
      name: 'profile',
      component(resolve) {
        require.ensure(['../pages/profile.vue'], () => {
          resolve(require('../pages/profile.vue'))
        })
      },
      meta: { requiresAuth: true }
    },
    // 查询详情页
    {
      path: '/product',
      name: 'product',
      component(resolve) {
        require.ensure(['../pages/product-detail.vue'], () => {
          resolve(require('../pages/product-detail.vue'))
        })
      },
      props: true,
      meta: { requiresAuth: true }
    },
    // 订单支付页
    {
      path: '/order-paid',
      name: 'order-paid',
      component(resolve) {
        require.ensure(['../pages/order-paid.vue'], () => {
          resolve(require('../pages/order-paid.vue'))
        })
      },
      props: true,
      meta: { requiresAuth: true }
    },
    // 订单详情页
    {
      path: '/order-detail/:orderId',
      name: 'order-detail',
      component(resolve) {
        require.ensure(['../pages/order-detail.vue'], () => {
          resolve(require('../pages/order-detail.vue'))
        })
      },
      meta: { requiresAuth: true }
    }
  ]
})
